package com.niuke;

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

/**
 * 54. 计算堆栈中的剩余数字
 * https://blog.csdn.net/A_D_I_D_A_S/article/details/131488412
 */
public class NiukeMoni54 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        String[] input = scanner.nextLine().split(" ");
        int[] data = new int[input.length];
        for (int i = 0; i < input.length; i++) {
            data[i] = Integer.parseInt(input[i]);
        }

        List<Integer> result = new LinkedList<>();
        result.add(data[0]);
        for (int i = 1; i < data.length; i++) {
            int curr = data[i];
            int num = 0;
            boolean needContinue = true;
            boolean needAdd = true;
            while (needContinue) {
                int start = result.size() - 1;
                if (!needAdd) {
                    start = start - 1;
                }
                for (int j = start; j >= 0; j--) {
                    num += result.get(j);
                    if (curr == num) {
                        result.subList(j, result.size()).clear();
                        result.add(2 * curr);
                        curr = 2 * curr;
                        num = 0; // 重置
                        needAdd = false;
                        if (result.size() == 1) {
                            needContinue = false;
                        }
                        break;
                    } else if (curr < num) {
                        needContinue = false;
                        break;
                    }

                    if (j == 0) { // 循环尽了都没符合终止条件，进行一次最终终止
                        needContinue = false;
                    }
                }
            }

            if (needAdd) {
                result.add(curr);
            }
        }

        for (int i = 0; i < result.size(); i++) {
            if (i == result.size() - 1) {
                System.out.println(result.get(i));
            } else {
                System.out.print(result.get(i) + " ");
            }
        }

    }

}
